
package base;

import java.util.*;

/**
 * this class is used to deal with the products
 * @Author FlowerYang
 */
public class Product_Catalog {

    /**
     * Default constructor
     */
    Vector<Product>Products;
    public Product_Catalog() {
        Products=new Vector<Product>();
    }

    /**
     * @param product
     */
    public void addProduct(Product product) {
        Products.add(product);
    }

    /**
     * @param code
     * @return
     */
    public Product getProduct(String code) {
        for (Product P : Products)
            if (P.getCode().equals(code))
                return P;
        return null;
    }

    /**
     * @return
     */
    public int getNumberOfItems() {
        int sum=0;
        for (Product P:Products)
            sum+=P.getNumber();
        return sum;
    }

    /**
     * 
     */
    public void showAllItems() {
        for (Product P:Products)
            P.showProduct();
    }
}